<template lang="pug">
.select-time-wrap
	.time-head-wrap
		.time-head
			p {{submitUserInfo.date}} {{submitUserInfo.week}} {{submitUserInfo.outTime}}
			.rest-num
				.num 总10{{}}
				.num.rest 余3
		.department {{submitUserInfo.department}}
	.time-group
		.time-block(v-for="(item,index) in list" :key="index" @click="submit(item)") {{item.time}} {{item.yysjd_num}}号
</template>

<script>
export default {
	name: 'selectTime',
	data() {
		return {
			submitUserInfo: {},
			list: []
		}
	},
	created() {},
	mounted() {
		this.submitUserInfo = this.wx.getStorageSync('submitUserInfo')
		this.outTime = this.$route.query.outTime === 'a' ? '上午' : '下午'
		this.restNum = this.$route.query.restNum
		this.selectTime()
	},
	methods: {
		selectTime() {
			this.wx.showLoading({
				title: '加载中',
				icon: 'none'
			})
			this.api.jtApi
				.selectTime({
					schedule_num: this.$route.query.scheduleNum.toString()
				})
				.then(data => {
					this.wx.hideLoading()
					if (data.ret_code === '0') {
						let list = this.tools.formatToArray(data.yysjdlist.yysjd_body)
						list.forEach(item => {
							item.time = item.yysjd.substr(11, 5)
						})
						this.list = list
					}
				})
				.catch(err => {
					this.wx.hideLoading()
				})
		},
		submit(item) {
			this.$router.push({
				path: '/views/bespeak/submit'
			})
		}
	}
}
</script>

<style lang="stylus">
	.select-time-wrap
		.time-head-wrap
			position fixed
			top 0
			right 0
			left 0
			height 110px
			z-index 10
			padding 12px mainPadding 0
			background-color white
			box-sizing border-box
			.time-head
				display flex
				justify-content space-between
				p
					font-size 30px
					font-weight 500
					color blackFontColor1A
					line-height 44px
				.rest-num
					display flex
					.num
						padding 0 20px
						height 36px
						line-height 36px
						border 1px solid grayFontColor88
						border-radius 18px
						color grayFontColor88
						font-size 22px
						margin-left 16px
						&.rest
							border-color #F73030
							color #F73030
			.department
				font-size 24px
				color grayFontColor
				line-height 34px
		.time-group
			position relative
			padding 110px mainMargin 0
			display flex
			justify-content space-between
			flex-wrap wrap
			.time-block
				width 348px
				height 84px
				line-height 84px
				text-align center
				color blackFontColor1A
				background-color white
				border-radius 4px
				margin-bottom 10px
				font-size 30px
				&:first-child,&:nth-child(2)
					margin-top 24px
</style>
